package vfs.obj.association.impl;


import java.sql.Connection;
import vfs.filter.VFSFilter;
import vfs.obj.association.VFSNodeOwnedByUser;
import vfs.obj.entity.VFSUser;
import vfs.obj.entity.VFSNode;
import vfs.persist.association.VFSNodeOwnedByUserManager;
import vfs.persist.association.impl.VFSNodeOwnedByUserManagerImpl;
import java.util.Iterator;

/**
 * VFSNodeOwnedByUser is an association manipulator capable of 
 * manipulating the ownership relationship between Nodes and Users.
 * 
 * @author Matthew Eavenson <durandal@uga.edu>
 */
public class VFSNodeOwnedByUserImpl implements VFSNodeOwnedByUser{
    
    private VFSNodeOwnedByUserManager manager;
    
    public VFSNodeOwnedByUserImpl(Connection conn){
        manager = new VFSNodeOwnedByUserManagerImpl(conn);
    }
    
    /**
     * Returns an iterator over all nodes owned by a specified user,
     * and filtered by a specified filter.
     * 
     * @param user the owner of the requested nodes
     * @param filter a filter over the nodes owned by the specified user
     * @return an iterator over any matching nodes
     */
    @Override
    public Iterator<VFSNode> getNodes(VFSUser user, VFSFilter filter){
        return manager.getNodes(user, filter);
    }
    
    /**
     * Returns the owner of a specified node.
     * 
     * @param node the node whose owner is requested
     * @return the owner of the specified node
     */
    @Override
    public VFSUser getOwner(VFSNode node){
        return manager.getOwner(node);
    }
    
    /**
     * Sets the owner of a specified node to a specified user.
     * 
     * @param node the node whose owner will be set
     * @param user the user to set as the owner of the specified node
     */
    @Override
    public void setOwner(VFSNode node, VFSUser user){
        manager.setOwner(node, user);
    }
    
}
